package net.asrsmid.invoker.as;

/**
 * An InvalidDataPrecisionException is thrown when the required data precision exceeds
 * the maximum allowed precision 
 * @author Chen WANG
 * @since 20 June 2011
 */
public class InvalidDataPrecisionException extends TableException {
	private static final long serialVersionUID = 1L;

	/**
	 * Constructs an InvalidDataPrecisionException when the given fields
	 * @param pre a required precision
	 * @param maxPrecision max allowed exception
	 */
	public InvalidDataPrecisionException(int precision, int maxPrecision) {
		super(composeMsg(precision, maxPrecision));
	}
	
	private static String composeMsg(int pre, int maxPrecision) {
		StringBuilder sb = new StringBuilder();
		
		sb.append("Invalide data precision ").append(pre);
		sb.append(". Min supported precision: 0, max supported precision ");
		sb.append(maxPrecision);
		
		return sb.toString();
	}
}
